package com.headwind.retry.service.impl;

import com.headwind.error.BusinessException;
import com.headwind.retry.service.RetryService;
import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.Retryable;
import org.springframework.stereotype.Service;

/**
 * @author : Headwind
 * @version : 1.0
 * @date : Created in 2020/8/12
 * @description : 重试接口实现类
 */
@Service
public class RetryServiceImpl implements RetryService {
    @Override
    @Retryable(value = {BusinessException.class}, maxAttempts = 5,
            backoff = @Backoff(delay = 5000, multiplier = 2))
    public String findByUserId(String userId) {
        System.out.println("【findByUserId】 方法失败重试了！");
//        throw new BusinessException();
        return "{\"userId\":\"A123\"}";
    }


}
